<?php

function fnMstSupplier() {
    $results = mysql_query("SELECT
                                Id,
                                Nama,
                                Alamat,
                                Telepon,
                                Email
                            FROM
                                mst_supplier");
    return $results;
}

function fnSupplierById($id) {
    $results = mysql_query("SELECT	
                                Nama,
                                Alamat,
                                Telepon,
                                Email
                            FROM
                                mst_supplier
                            WHERE id = ".$id);
    return $results;
}

function fnAllSupplier() {
    $results = mysql_query("select c.* from (
                            select @rownum:=@rownum+1 as rownum, a.*
                            from mst_supplier a, (select @rownum:=0) b
                            ) c ");
    return $results;
}

function fnAllSupplierByRange($startNum, $endNum) {
    $results = mysql_query("select c.* from (
                            select @rownum:=@rownum+1 as rownum, a.*
                            from mst_supplier a, (select @rownum:=0) b
                            ) c where 1=1
                            and c.rownum between ".$startNum." and ".$endNum);
    return $results;
}

function fnInsertSupplier($Nama,$Alamat,$Telp,$Email) {
  $result = mysql_query("INSERT INTO mst_supplier 
                          	(Nama,Alamat,Telepon,Email)
                         VALUES
                          	('$Nama','$Alamat','$Telp','$Email')
                         ");
  return $result;
}

function fnUpdateSupplier($Id,$Nama,$Alamat,$Telp,$Email) {
  $result = mysql_query("UPDATE mst_supplier SET 
                              	Nama = '$Nama',
                              	Alamat = '$Alamat',
                              	Telepon = '$Telp',
                              	Email = '$Email'
                         WHERE Id = $Id");
  return $result;
}

function fnDeleteSupplier($Id) {
  $result = mysql_query("DELETE FROM mst_supplier 
                         WHERE Id = ".$Id);
  return $result;
}

?>
